#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

a = sys.stdin.readline().strip()
a = a.split(' ')
low = int(a[0])
high = int(a[1])
a_list = []
z_list = []
for i in range(low, high):
    for j in range(2, int(i ** 0.5 + 2)):
        if i % j == 0:
            a_list.append(i)
a_list = list(set(a_list))
print(a_list)
if len(a_list) == 0:
    print(0)
else:
    for y in range(low, high):
        if y not in list(set(a_list)):
            z_list.append(y)
    # 个位数,十位数
    g_list, s_list = [], []
    for x in z_list:
        g_list.append(x % 10)
        s_list.append((x % 100 - x % 10) // 10)
    g_int, s_int = 0, 0
    for g in g_list:
        g_int += g
    for s in s_list:
        s_int += s
    if g_int < s_int:
        print(g_int)
    else:
        print(s_int)
